import requestMeeting, { request } from '@/plugins/axios'
import { FetchTVWallListItem, FetchTVWallItem, IChannelProps, SaveTVWallItem } from './interface'
/** 获取电视墙风格列表 */
export const fetchLoadTVWall = async (currentPage: number) =>
	requestMeeting<FetchTVWallListItem[]>({
		url: '/tvwall_styles',
		method: 'get',
		params: {
			start: (currentPage - 1) * 20,
			count: 20,
			order: 1,
		},
	}).then((res) => res)

/** 获取某个电视墙风格 */
export const fetchGetTVWallById = async (id: string) =>
	request<FetchTVWallItem>({
		url: `/tvwall_styles/${id}`,
		method: 'get',
	}).then((res) => (res.success ? res : undefined))

/** 删除电视墙风格 */
export const fetchDeleteTVWall = async (styles: { id: string; name: string }[]) =>
	requestMeeting<boolean>({
		url: '/tvwall_styles',
		method: 'delete',
		data: { styles },
	}).then((res) => res)

/** 新增电视墙风格 */
export const fetchSaveTVWall = async (tvWallTemplate: SaveTVWallItem) =>
	requestMeeting<boolean>({
		url: '/tvwall_styles',
		method: 'post',
		data: tvWallTemplate,
	}).then((res) => res)

/** 编辑电视墙风格 */
export const fetchEditTVWall = async (tvWallTemplate: SaveTVWallItem, id: string) =>
	requestMeeting<boolean>({
		url: `/tvwall_styles/${id}`,
		method: 'put',
		data: tvWallTemplate,
	}).then((res) => res)

/** 获取通道列表 */
export const fetchLoadVenners = async () =>
	request<{ list: IChannelProps[] }>({
		url: '/tvwalls/veneers',
		method: 'get',
	}).then((res) => (res.success ? res.list ?? [] : undefined))
